test: standardize unit tests across all services (31 tests)#54
Open
test: standardize unit tests across all services (31 tests)#54
Conversation
- Update Contract model to use String type for contractCreated and contractLastModifiedOn fields - Remove Long::valueOf conversions in ResponseParser when parsing timestamp values from DynamoDB - Align timestamp handling with string-based storage in DynamoDB AttributeValue - Simplifies type conversion and maintains consistency with data source format
…lerFunction and add metrics - Rename class from ContractEventHandler to ContractEventHandlerFunction for consistency - Update all constructor references to use new class name - Update logger initialization to reference new class name - Add metrics tracking for ContractCreated and ContractUpdated events - Reorganize imports to follow alphabetical ordering - Change timestamp fields from Long (epoch millis) to String (ISO-8601 format) - Update DynamoDB attribute builders to use string type for timestamp fields - Clean up whitespace inconsistencies throughout the file
…entHandlerFunction - Update handler field type from ContractEventHandler to ContractEventHandlerFunction - Update handler instantiation in setUp() to use ContractEventHandlerFunction constructor - Align test class with recent refactoring that renamed ContractEventHandler to ContractEventHandlerFunction
- Import Powertools metrics classes (Metrics, MetricsFactory, MetricUnit) - Add validation for evaluation results (APPROVED/DECLINED) in PublicationEvaluationEventHandler - Track PropertiesApproved metric when property status is updated - Add SERVICE_NAMESPACE environment variable to RequestApprovalFunction - Expand RequestApproval event payload with status, listprice, images, description, and currency fields - Add corresponding getters and setters for new RequestApproval properties - Use SERVICE_NAMESPACE for EventBridge event source instead of hardcoded "Unicorn.Web" - Track ApprovalsRequested metric when events are sent to EventBridge - Improve code formatting and consistency
Migrate to JUnit 5, add coverage tooling (JaCoCo, 80% minimum), create test helpers and event fixtures, extend test cases for all 7 Lambda functions, and remove extra tests to ensure parity with Python, .NET, and TypeScript runtimes.
|
No related issues found. Please ensure there is an open issue related to this change to avoid significant delays or closure. |
|
No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template here: https://github.com/aws-samples/aws-serverless-developer-experience-workshop-java/blob/develop/.github/PULL_REQUEST_TEMPLATE.md#acknowledgment |
Add raw payload JSON fixtures and loadEvent/createSqsEvent helpers. Refactor tests to load payloads from files instead of inline strings. Remove 10 stale event files no longer used by tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue number: N/A
Summary
Changes
Standardize unit tests across all 4 Java modules to achieve exact parity with the Python, .NET, and TypeScript runtimes (31 identical test cases across 7 Lambda functions).
mockito-junit-jupiteracross all test modulesjacoco-maven-pluginwith 80% line coverage minimum to all 4pom.xmlfiles (with exclusions for schema/DAO/model classes)TestHelpers.javaclasses with Lambda context factories, SQS/EventBridge/DynamoDB Stream event builders, and JSON fixture loadingPropertiesApprovalSyncFunctionTests.java,WaitForContractApprovalFunctionTests.java,RequestApprovalFunctionTests.java,PublicationEvaluationEventHandlerTests.java,PropertySearchFunctionTests.javanull event,empty event,missing HttpMethod,empty body) to align test cases across runtimesUser experience
Workshop participants running
mvn testwill see the same 31 test cases as in the other 3 runtimes, with 80% coverage enforced via JaCoCo at build time. All tests use JUnit 5 annotations and Mockito mocks.Checklist
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.